import '~/global';
import {createAppContainer, createSwitchNavigator} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import Start from '~/pages/start/index';
import Ads from '~/pages/start/ads';
import SelectRole from '~/pages/selectlogin/selectrole'; //选择角色
import Login from '~/pages/selectlogin/login/index'; //登录
import Sign from '~/pages/selectlogin/sign/sign'; //注册
import SignForm from '~/pages/selectlogin/sign/SignForm'; //注册
import Agreement from '~/pages/selectlogin/sign/agreement'; //用户协议
import NavigatorTab from '~/pages/navigatortab/NavigatorTab';
import HomeStack from './home';
import DeveloperStack from './developer';
import MyStack from './my';

const navigationOptions = {
    title: '',
    headerTitleAlign: 'center',
};

const AppList = {
    NavigatorTab,
    Login,
    Sign,
    SignForm,
    Agreement,
    ...HomeStack,
    ...DeveloperStack,
    ...MyStack,
};
const AppStack = createStackNavigator(AppList, {
    defaultNavigationOptions: navigationOptions,
});

let stackList = {
    AppStack,
};

if (global.AppData.versionName === 'dev') {
    const AuthList = {SelectRole};
    const AuthStack = createStackNavigator(AuthList, {
        defaultNavigationOptions: navigationOptions,
    });
    stackList = Object.assign({AuthStack}, stackList);
}

const SplashList = {
    Start,
    Ads,
};
const SplashStack = createStackNavigator(SplashList, {
    defaultNavigationOptions: {...navigationOptions, animationEnabled: false},
});
stackList = Object.assign({SplashStack}, stackList);

const AppContainer = createAppContainer(createSwitchNavigator(stackList));

export default AppContainer;
